<template>
  <el-dropdown :show-timeout="100" trigger="click">
    <el-button plain>
      {{ !comment_disabled ? 'Comment: opened' : 'Comment: closed' }}
      <el-icon class="el-icon--right" style="vertical-align: middle;">
        <CaretBottom />
      </el-icon>
    </el-button>
    <template #dropdown>
      <el-dropdown-menu class="no-padding">
        <el-dropdown-item>
          <el-radio-group v-model="comment_disabled" style="padding: 10px;">
            <el-radio :label="true">
              Close comment
            </el-radio>
            <el-radio :label="false">
              Open comment
            </el-radio>
          </el-radio-group>
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script>
export default {
  name: 'ComDropdown'
}
</script>

<script setup>
import { CaretBottom } from '@element-plus/icons-vue'
import { defineProps, computed, defineEmits } from 'vue'

const props = defineProps({
  modelValue: {
    type: Boolean,
    default: false
  }
})

const emits = defineEmits(['update:modelValue'])

const comment_disabled = computed({
  get() {
    return props.modelValue
  },
  set(val) {
    emits('update:modelValue', val)
  }
})
</script>

<style lang="scss" scoped>
.button-c {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
